﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace PSE.AuditLogging.Client.Configuration
{
    [ConfigurationCollection(typeof(StorageConfigurationElement), AddItemName = "storage")]
    public class StorageConfigurationElementCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new StorageConfigurationElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((StorageConfigurationElement)element).Id;
        }

        public new StorageConfigurationElement this[string key]
        {
            get
            {
                return (StorageConfigurationElement)BaseGet(key);
            }
        }

        public new StorageConfigurationElement this[int index]
        {
            get
            {
                return (StorageConfigurationElement)BaseGet(index);
            }
        }

        public void Add(StorageConfigurationElement item)
        {
            base.BaseAdd(item);
        }

        public void Remove(string productId)
        {
            if (base.BaseGet(productId) != null) //se existe
                base.BaseRemove(productId);
        }
    }
}
